<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 冒充继承 = 浅拷贝+ 寄生继承

        function Person(name,age){  
              this.name = name;
              this.age = age; 
        }

        Person.prototype.sayHello = function(){
            console.log('我是原型继承');
        }
        const p = new Person('张三',18);

        function Student(gender){
            this.gender = gender;
            Object.assign(this,p);
            // this 是新对象 
            // 也就是Student的实例

        }
        Student.prototype = Person.prototype; // 寄生继承
        const s1 = new Student('男');
        console.log(s1);
    </script>
</body>
</html>